/*
 * Listen.java
 *
 * Created on May 13, 2009, 5:17 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package im.general;

import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;

/**
 *
 * @author bluejack
 */
public abstract class AbstractListenBehaviour extends CyclicBehaviour {
    
    /** Creates a new instance of Listen */
    public AbstractListenBehaviour() {
    }

    public void action() {
        ACLMessage msg = myAgent.receive();
        if (msg != null) {
            manageMessage(msg);
        }
        else
            block();
    }

    protected abstract void manageMessage(ACLMessage msg);
    
    protected void sendMessage(ACLMessage msg) {
        myAgent.send(msg);
    }
    
}
